﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ModelDesignEduse.TableProjection;
using MySql.Data.MySqlClient;

namespace ModelDesignEduse.Framework
{
    public static class CRUD
    {
        static MySqlConnection conn;

        public static void LoadDatabase()
        {
            conn = new MySqlConnection("Server=localhost;Port=3306;Database=eduse;Uid=root;Pwd=admin;pooling=false;");
            conn.Open();
        }

        public static void ExecuteCommandNoReturn(string query)
        {
            MySqlCommand comm = new MySqlCommand(query, conn);

            comm.ExecuteNonQuery();
        }

        public static object ExecuteCommandScalar(string query)
        {
            MySqlCommand comm = new MySqlCommand(query, conn);

            return comm.ExecuteScalar();
        }

        public static MySqlDataReader ExecuteCommandList(string query)
        {
            MySqlCommand comm = new MySqlCommand(query, conn);

            return comm.ExecuteReader();
        }

    }
}
